<?php

/**
 *      [品牌空间] (C)2001-2010 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: domain.inc.php 4463 2010-09-15 02:00:55Z yumiao $
 */

if(!defined('IN_ADMIN')) {
	exit('Acess Denied');
}

$allowdomain = intval($_POST['allowdomain']);
$holddomain = saddslashes($_POST['holddomain']);
$domainroot = saddslashes($_POST['domainroot']);
$siteurl = saddslashes($_POST['siteurl']);

if(submitcheck('valuesubmit')){

	$checkresults = array();

	if($allowdomain == 1 && empty($domainroot)) array_push($checkresults, array('domainroot'=>lang('setting_domain_null_error')));
	if(preg_match('/^((http|https|ftp):\/\/|\.)|(\/|\.)$/i', $domainroot)) array_push($checkresults, array('domainroot'=>lang('setting_domain_http_error')));
	if(!empty($checkresults)) {
		cpmsg('add_error', '', 'error', '', true, true, $checkresults);
	}

	DB::query("REPLACE INTO ".DB::table('settings')." (`variable`, `value`) VALUES
		('allowdomain', '$allowdomain'),
		('holddomain', '$holddomain'),
		('domainroot', '$domainroot'),
		('siteurl', '$siteurl')
	");
	updatesettingcache();

	cpmsg('update_success', '?action=domain');
}

shownav('global', 'nav_domain');
showsubmenu('nav_domain');
showtips('nav_domain_tips');
showformheader('domain');
showtableheader('');
showsetting('global_allowdomain', array('allowdomain', array(
	array(1, lang('yes')),
	array(0, lang('no'))
	), true), $_G['setting']['allowdomain'], 'mradio');
showsetting('global_holddomain', 'holddomain', $_G['setting']['holddomain'], 'text');
showsetting('global_domainroot', 'domainroot', $_G['setting']['domainroot'], 'text');
showsetting('global_siteurl', 'siteurl', $_G['setting']['siteurl'], 'text');
showsubmit('valuesubmit');
showtablefooter();
showformfooter();
bind_ajax_form();

?>